<template>
    <li class="goods">
        <router-link :to="`/goods/detail?id=${good.id}`">
            <a class="goods-link" href="#">
                <div class="goods-image">
                    <img :src="good.mainImage" alt="商品图片" />
                </div>
                <h3 class="goods-title">{{ good.title }}</h3>
                <p class="goods-desc">{{ good.description }}</p>
                <div class="goods-price">￥{{ good.price }}</div>
            </a>
        </router-link>
    </li>
</template>

<script setup>

const props = defineProps({
    good: {
        type: Object,
        required: true
    }
})
</script>

<style scoped>
.goods {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s, box-shadow 0.3s;
}
.goods:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.goods-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}
.goods-image {
    width: 100%;
    height: 180px;
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.goods-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.goods-image:hover img {
    transform: scale(1.05);
}
.goods-title {
    font-size: 16px;
    font-weight: bold;
    color: #222;
    margin: 0 0 6px 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.goods-desc {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: 36px;
}
.goods-price {
    color: #ff4d4f;
    font-size: 18px;
    font-weight: bold;
    margin-top: 4px;
}
</style>
